/**
 * 本地存储
 * @module Store
 */
let Store = {
    get: function (key) {
        var value = wx.getStorageSync(key);
        if (value) {
            try {
                var value_json = JSON.parse(value);
                if (typeof value_json === 'object') {
                    return value_json;
                } else if (typeof value_json === 'number') {
                    return value_json;
                }
            } catch (e) {
                return value;
            }
        } else {
            return false;
        }
    },
    set: function (key, value) {
        if (!value) {
            return false
        }
        try {
            wx.setStorageSync(key, value)
        } catch (e) {
            wx.setStorageSync(key, value)
        }
    },
    remove: function (key) {
        wx.removeStorageSync(key);
    },
    clear: function () {
        try {
            wx.clearStorageSync();
        } catch (e) {
        }
    }
};


export default Store;
